//
//  YBApiManager+Login.m
//  ChangChat
//
//  Created by Cocoa on 2019/9/2.
//  Copyright © 2019 yibai. All rights reserved.
//

#import "YBApiManager+Login.h"

@implementation YBApiManager (Login)
- (RACSignal *)getNewestVersion {
    NSDictionary *param = @{@"type": @"ios"};
    return [self sendGetRequest:@"index/version" param:param];
}
- (RACSignal *)getMobileCodeWithMobile:(NSString *)mobile event:(NSString *)event {
    NSDictionary *param = @{@"mobile": mobile,
                            @"event": event
                            };
    return [self sendGetRequest:@"sms/send" param:param];
}
- (RACSignal *)loginWithMobile:(NSString *)mobile password:(NSString *)password {
    NSDictionary *param = @{@"account": mobile,
                            @"password": password
                            };
    return [self sendGetRequest:@"user/login" param:param];
}
- (RACSignal *)registerWithMobile:(NSString *)mobile password:(NSString *)password code:(NSString *)code sex:(NSString *)sex username:(NSString *)username QQ:(NSString *)QQ {
    NSDictionary *param = @{@"mobile": mobile,
                            @"password": password,
                            @"gender": sex,
                            @"captcha": code,
                            @"username": username,
                            @"QQ": QQ
                            };
    return [self sendGetRequest:@"user/register" param:param];
}
- (RACSignal *)resetPwdWithMobile:(NSString *)mobile password:(NSString *)password repeatPwd:(NSString *)repeatPwd code:(NSString *)code {
    NSDictionary *param = @{@"mobile": mobile,
                            @"newpassword": password,
                            @"againpwd": repeatPwd,
                            @"captcha": code
                            };
    return [self sendGetRequest:@"user/resetpwd" param:param];
}

- (RACSignal *)changeMobileWithMobile:(NSString *)mobile captcha:(NSString *)captcha {
    NSDictionary *param = @{@"mobile": mobile,
                            @"captcha": captcha
                            };
    return [self sendGetRequest:@"user/changemobile" param:param];
}
@end
